package 网络编程;

import thread.ServerThread;

import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;

public class MyServerSocket extends Thread{
    public static List<Socket> onLineSockets = new ArrayList<>();
    public static void main(String[] args) throws Exception {
        System.out.println("--------服务端启动成功--------");
        ServerSocket serverSocket = new ServerSocket(6789);
//        ExecutorService pool = new ThreadPoolExecutor(3, 5, 2000, 
//                TimeUnit.SECONDS, new ArrayBlockingQueue<>(4), Executors.defaultThreadFactory(),
//                new ThreadPoolExecutor.AbortPolicy());
        while (true) {
            Socket socket = serverSocket.accept();
            Thread thread = new ServerThread(socket);
            onLineSockets.add(socket);
            thread.start();
            System.out.println(socket.getRemoteSocketAddress() + " 上线了");
        }

        
    }
    
}
